package org.come.Jpanel;

import com.tool.btn.DepositBtn;
import com.tool.btn.FormsOnOffBtn;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;
import org.come.mouslisten.PetDepositJlistChoseMouslisten;
import org.come.until.ScrollUI;
import org.come.until.SrcollPanelUI;

import javax.swing.*;
import java.awt.*;
import java.util.List;



public class DepositListJpanel extends JPanel {

    private JScrollPane jScrollPane; // 召唤兽列表滚动条
    private JList<String> listpet;// 召唤兽列表
    private DefaultListModel<String> listModel;// 放置召唤兽的对象
    private DepositBtn btntop,// 向上图标

            btnbottomset;// 置底图标
    private JLabel labOpen;
    private JLabel labLocking;
    public JLabel labgundong = new JLabel(new ImageIcon("inkImg/hongmu/2/gundongtiao_副本.png"));
    public DepositListJpanel() {
        String style = MyIsif.getStyle();
        if ("水墨UI".equals(style)) {
        this.labgundong.setBounds(162, 64, 17, 169);
//		this.add(this.labgundong);
        this.setPreferredSize(new Dimension(293, 409));
        this.setLayout(null);
        this.setBackground(UIUtils.Color_BACK);

        // 关闭按钮事件
        FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/old/2/1.png", 1, 63333);
        offBtn.setBounds(293, 5, 25, 25);
        this.add(offBtn);

        listModel = new DefaultListModel<String>();

        // 召唤兽列表
        listpet = new JList<String>() {
            {
                setOpaque(false);
            } // instance initializer
        };
        listpet.setSelectionBackground(new Color(33, 42, 52));
        listpet.setFont(new Font("微软雅黑", 1, 14));
        listpet.setBackground(UIUtils.Color_BACK); // 设置列表框为透明背景
        listpet.setForeground(Color.green);
        listpet.setSelectionForeground(Color.green);
        listpet.setModel(listModel);
//		listpet.addMouseListener(new PetJlistChoseMouslisten(listpet, this));
        listpet.addMouseMotionListener(new PetDepositJlistChoseMouslisten(listpet, this));


        // 召唤兽列表滚动条
        jScrollPane = new JScrollPane(listpet);
        jScrollPane.setVerticalScrollBarPolicy(22);
        jScrollPane.getVerticalScrollBar().setUI(new SrcollPanelUI());
        jScrollPane.getViewport().setOpaque(false);
        jScrollPane.setOpaque(false);
        jScrollPane.setBounds(53, 46, 194, 278);
        jScrollPane.setBorder(BorderFactory.createLineBorder(new Color(31, 7, 8)));
        jScrollPane.setBorder(BorderFactory.createEmptyBorder());
        jScrollPane.setHorizontalScrollBarPolicy(31);
        this.add(jScrollPane);


        this.labOpen = new JLabel();
        this.labOpen.setBounds(31, 261, 15, 15);
        this.add(this.labOpen);
        this.labLocking = new JLabel();
        this.labLocking.setBounds(31, 282, 15, 15);
        this.add(this.labLocking);


        btnbottomset = new DepositBtn("skin/8100226/newbutton/B20.png", 1, UIUtils.COLOR_WHITE2, UIUtils.TEXT_HY88, "取回", 2, this);
        this.btnbottomset.setBounds(118, 340,59, 24);
        this.add(this.btnbottomset);
    }else {
        this.labgundong.setBounds(162, 64, 17, 169);
//		this.add(this.labgundong);
        this.setPreferredSize(new Dimension(293, 409));
        this.setLayout(null);
        this.setBackground(UIUtils.Color_BACK);

        // 关闭按钮事件
        FormsOnOffBtn offBtn = new FormsOnOffBtn("img/xy2uiimg/8_jpg.button.btn_close.jpg", 1, 63333);
        offBtn.setBounds(293, 5, 25, 25);
        this.add(offBtn);

        listModel = new DefaultListModel<String>();

        // 召唤兽列表
        listpet = new JList<String>() {
            {
                setOpaque(false);
            } // instance initializer
        };
        listpet.setSelectionBackground(new Color(33, 42, 52));
        listpet.setFont(new Font("微软雅黑", 1, 16));
        listpet.setBackground(UIUtils.Color_BACK); // 设置列表框为透明背景
        listpet.setForeground(Color.green);
        listpet.setSelectionForeground(Color.green);
        listpet.setModel(listModel);
//		listpet.addMouseListener(new PetJlistChoseMouslisten(listpet, this));
        listpet.addMouseMotionListener(new PetDepositJlistChoseMouslisten(listpet, this));


        // 召唤兽列表滚动条
        jScrollPane = new JScrollPane(listpet);
        jScrollPane.setVerticalScrollBarPolicy(22);
        jScrollPane.getVerticalScrollBar().setUI(new SrcollPanelUI());
        jScrollPane.getViewport().setOpaque(false);
        jScrollPane.setOpaque(false);
        jScrollPane.setBounds(72, 42, 194, 278);
        jScrollPane.setBorder(BorderFactory.createLineBorder(new Color(31, 7, 8)));
        jScrollPane.setBorder(BorderFactory.createEmptyBorder());
        jScrollPane.setHorizontalScrollBarPolicy(31);
        this.add(jScrollPane);


        this.labOpen = new JLabel();
        this.labOpen.setBounds(31, 261, 15, 15);
        this.add(this.labOpen);
        this.labLocking = new JLabel();
        this.labLocking.setBounds(31, 282, 15, 15);
        this.add(this.labLocking);

        btnbottomset = new DepositBtn("inkImg/hongmu/60_26.png", 1, UIUtils.COLOR_WHITE3, UIUtils.TEXT_HY99, "取 回", 2, this);
        this.btnbottomset.setBounds(118, 345,60, 26);
        this.add(this.btnbottomset);
    }
    }

    private ImageIcon icon;
    private ImageIcon icon1;

    @Override
    protected void paintComponent(Graphics g) {
        String style = MyIsif.getStyle();
        if ("水墨UI".equals(style)) {
        super.paintComponent(g);
        if (icon == null) {
            icon = new ImageIcon("inkImg/newbackground/B333.png");
        }
        // 背景
        g.drawImage(icon.getImage(), 0, 0, 293, 409, this);
        this.btnbottomset.setBounds(118, 340,59, 24);
        }else {
            super.paintComponent(g);
            if (icon1 == null) {
                icon1 = new ImageIcon("skin/8100226/button/hongmu/取回红木.png");
            }
            // 背景
            g.drawImage(icon1.getImage(), 0, 0, 293, 409, this);
            this.btnbottomset.setBounds(118, 340,59, 24);
        }
    }

    // 初始列表
    public void init(List<String> list) {
        listModel.clear();
        for (int i = 0; i < list.size(); i++) {
            listModel.addElement(list.get(i));
        }
    }

    public DefaultListModel<String> getListModel() {
        return listModel;
    }

    public void setListModel(DefaultListModel<String> listModel) {
        this.listModel = listModel;
    }

    public JList<String> getListpet() {
        return listpet;
    }

    public void setListpet(JList<String> listpet) {
        this.listpet = listpet;
    }

}
